package com.flyduck.vueshop.order.remote.service.impl;

import com.flyduck.vueshop.common.core.utils.BeanUtils;
import com.flyduck.vueshop.order.entity.AppOrderItem;
import com.flyduck.vueshop.order.mapper.AppOrderItemMapper;
import com.flyduck.vueshop.order.remote.service.RemoteOrderItemService;
import com.flyduck.vueshop.order.vo.RemoteOrderItemRespVO;
import com.flyduck.vueshop.order.vo.RemoteOrderItemUpdateReqVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * RemoteOrderItemServiceImpl
 * </p>
 *
 * @author flyduck
 * @since 2024-07-23
 */
@Service
public class RemoteOrderItemServiceImpl implements RemoteOrderItemService {

    @Resource
    private AppOrderItemMapper appOrderItemMapper;

    @Override
    public RemoteOrderItemRespVO getOrderItemById(Long id) {
        AppOrderItem appOrderItem = appOrderItemMapper.selectById(id);
        return BeanUtils.toBean(appOrderItem, RemoteOrderItemRespVO.class);
    }

    @Override
    public void updateOrderItem(RemoteOrderItemUpdateReqVO remoteOrderItemUpdateReqVO) {
        AppOrderItem appOrderItem = BeanUtils.toBean(remoteOrderItemUpdateReqVO, AppOrderItem.class);
        appOrderItemMapper.updateById(appOrderItem);
    }
}
